<template>
	<view class="word-page">
		<view v-show="NodeEnum.code===currentNode">
			<Code ref="refCode" :phone="phone" :codeType="codeType" @next="next" />
		</view>
		<view v-show="NodeEnum.pwd===currentNode">
			<Pwd ref="refPwd" :phone="phone" :codeType="codeType" @save="save" />
		</view>
	</view>
</template>

<script>
	import {
		VerCodeTypeEnum
	} from "@/enums/verCode"
	import {
		NodeEnum
	} from "./config"
	import Code from "./components/code/Code.vue"
	import Pwd from "./components/pwd/Pwd.vue"
	export default {
		components: {
			Code,
			Pwd
		},
		data() {
			return {
				codeType: VerCodeTypeEnum['忘记密码'],
				phone: "",
				currentNode: NodeEnum.code,
				NodeEnum,
			}
		},
		onLoad(options) {
			this.codeType = Number(options.type) ?? VerCodeTypeEnum['忘记密码'];
			this.phone = options.phone;
			uni.setNavigationBarTitle({
				title: VerCodeTypeEnum[this.codeType]
			})
		},
		onReady() {
			this.$refs.refCode.init();
		},
		methods: {
			next(e) {
				if (e) this.currentNode = NodeEnum.pwd
			},
			save(e) {
				if (e) {
					setTimeout(() => {
						uni.reLaunch({
							url: "/pages/login/login"
						})
					}, 1000);
				}
			}
		},
	}
</script>

<style lang="less" scoped>
	@import url("@/pages/login/css/login.css");

	.word-page {
		background-color: #ffffff;
		padding: 100rpx 30rpx 30rpx 30rpx;
		height: 100vh;


	}
</style>
